require 'test/unit'
require 'lib/smppclient/pdu/bind_transmitter_resp'

class TestBindTransmitterResp < MiniTest::Unit::TestCase

  include SmppClient::Pdu
  include SmppClient::Util

  def test_bytes_to_object
    bb = ByteBuffer.new
    bb.append_int(28)
    bb.append_int(0x80000002)
    bb.append_int(0)
    bb.append_int(70)
    bb.append_cstring('simple resp')

    brr = BindTransmitterResp.new(bb)
    assert_equal(28, brr.command_length)
    assert_equal(CommandId::BIND_TRANSMITTER_RESP, brr.command_id)
    assert_equal(CommandStatus::ESME_ROK, brr.command_status)
    assert_equal(70, brr.sequence_number)
    assert_equal('simple resp', brr.system_id)
  end

  def test_object_to_bytes
    brr = BindTransmitterResp.new
    brr.command_status = CommandStatus::ESME_ROK
    brr.sequence_number = 100000000
    brr.system_id = 'systemaida'
    assert_equal('0000001b800000020000000005f5e10073797374656d6169646100', brr.buffer.to_s)
  end

end